
# ==============================================================================
#                              Build options
# ==============================================================================
OPTION(BUILD_SHARED_LIBS "Build dynamic libraries" OFF)


# COMMON flags (all CMAKE_BUILD_TYPE: Standard, Debug, Realease, ...)
# ==============================================================================

# # Template :
# SET(PYLOT_C_FLAGS "${PYLOT_C_FLAGS} -flag-CXX")
# SET(PYLOT_CXX_FLAGS "${PYLOT_CXX_FLAGS} -flag-C")


# OpenMP Flags
# INCLUDE(FindOpenMPpyLot)
# IF(OPENMP_FOUND)
#   SET(PYLOT_C_FLAGS "${PYLOT_C_FLAGS} ${OpenMP_C_FLAGS}")
#   SET(PYLOT_CXX_FLAGS "${PYLOT_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# ENDIF(OPENMP_FOUND)

# "STANDARD" build (CMAKE_BUILD_TYPE = "")
# ==============================================================================
IF(CMAKE_BUILD_TYPE STREQUAL "")
  # Optimization
  SET(PYLOT_CXX_FLAGS "${PYLOT_CXX_FLAGS} -O3 -ftree-vectorize")
  SET(PYLOT_C_FLAGS "${PYLOT_C_FLAGS} -O3 -ftree-vectorize")
  # -ftree-vectorize is included in -O3 in gcc 4.3

# "Debug" build (CMAKE_BUILD_TYPE = "Debug")
# ==============================================================================
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Debug")

  # Gdb
  SET(PYLOT_CXX_FLAGS "${PYLOT_CXX_FLAGS} -ggdb")

  # GCC flags
  IF(${CMAKE_COMPILER_IS_GNUCXX})
    SET(PYLOT_CXX_FLAGS "${PYLOT_CXX_FLAGS} -Wreturn-type")
    SET(PYLOT_C_FLAGS "${PYLOT_C_FLAGS} -Wreturn-type")
  ENDIF(${CMAKE_COMPILER_IS_GNUCXX})

# "OTHER" build (CMAKE_BUILD_TYPE = "Realease, MinSizeRel, RelWithDebInfo")
# ==============================================================================
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Realease")
  # no additionnal flags
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
  # no additionnal flags
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
  # no additionnal flags
ENDIF(CMAKE_BUILD_TYPE STREQUAL "")


# Define CMAKE_CXX_FLAGS = PYLOT_CXX_FLAGS + CMAKE_CXX_FLAGS
# (final flags) = (user flags defined in this file) + (default cmake flags)
IF(CMAKE_BUILD_TYPE STREQUAL "")
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PYLOT_CXX_FLAGS}")
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PYLOT_C_FLAGS}")
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} ${PYLOT_CXX_FLAGS}")
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_DEBUG} ${PYLOT_C_FLAGS}")
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Realease")
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_REALEASE} ${PYLOT_CXX_FLAGS}")
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_REALEASE} ${PYLOT_C_FLAGS}")
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_MINSIZEREL} ${PYLOT_CXX_FLAGS}")
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_MINSIZEREL} ${PYLOT_C_FLAGS}")
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${PYLOT_CXX_FLAGS}")
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${PYLOT_C_FLAGS}")
ENDIF(CMAKE_BUILD_TYPE STREQUAL "")




# ==============================================================================
#                            Miscellaneous options
# ==============================================================================

SET(DOXYGEN_LANGUAGE "English" CACHE STRING "Doxygen language")
